package com.lagou.server.provider.anno.service.impl;

import com.lagou.server.api.ShoppingService;
import org.apache.dubbo.config.annotation.DubboService;

import java.util.Random;

/**
 * @author caiwei
 * @date 2020-11-6 0:23
 */
@DubboService
public class ShoppingServiceImpl implements ShoppingService {

    final Random r = new Random();
    @Override
    public String order() {
        randomSleep();
        return "下单成功";
    }

    @Override
    public String pay() {
        randomSleep();
        return "付款成功";
    }

    @Override
    public String deliver() {
        randomSleep();
        return "发货成功";
    }

    private void randomSleep(){
        try {
            Thread.sleep(r.nextInt(1000));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
